package org.hu.entity.vo;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private Integer code; //状态码，1表示成功，0表示失败
    private String message; // 提示信息
    private Object data; // 返回数据

    //成功返回,不需要数据
    public static <T> Result<T> success(String message){
        Result<T> result = new Result<T>();
        result.setCode(1);
        result.setMessage(message);
        return result;
    }


    //成功返回，有数据
    public static <T> Result<T> success(String message,T data){
        Result<T> result = new Result<T>();
        result.setCode(1);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    //失败返回
    public static <T> Result<T> fail(String message){
        Result<T> result = new Result<T>();
        result.setCode(0);
        result.setMessage(message);
        return result;
    }

}
